package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.math.Vector2;
import com.corona.Game;
import com.corona.game.util.TextureCache;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;

/* compiled from: Player.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawItemPickup.class */
public class DrawItemPickup extends Action {
    HashMap<String, Integer> items;
    ArrayList<String> words = new ArrayList<>();
    ArrayList<Color> wordColors = new ArrayList<>();
    Vector2 topLeft = new Vector2(89.0f, 144.0f);
    int timer = 0;
    Color color = new Color();
    Sprite textBoxTop = new Sprite(TextureCache.get(Gdx.files.internal("menu/selected_menu_top.png")), 0, 0, 71, 19);
    Sprite textBoxMiddle = new Sprite(TextureCache.get(Gdx.files.internal("menu/selected_menu_middle.png")), 0, 0, 71, 16);
    Sprite textBoxBottom = new Sprite(TextureCache.get(Gdx.files.internal("menu/selected_menu_bottom.png")), 0, 0, 71, 19);

    public DrawItemPickup(HashMap<String, Integer> items, Action nextAction) {
        super(new Object[0]);
        this.items = items;
        this.nextAction = nextAction;
        this.words.clear();
        this.wordColors.clear();
        this.words.add("GOT");
        this.wordColors.add(new Color(1.0f, 1.0f, 1.0f, 1.0f));
        for (String item : this.items.keySet()) {
            String[] texts = item.toUpperCase(Locale.ROOT).split(" ");
            for (int i = 0; i < texts.length; i++) {
                String text = texts[i];
                if (text.contains("APRICORN")) {
                    text = "APRCN";
                } else if (text.equals("BEDDING")) {
                    text = "BED";
                }
                if (i >= texts.length - 1) {
                    int numGot = this.items.get(item).intValue();
                    int length = text.length();
                    for (int j = 0; j < 5 - length; j++) {
                        text = text + " ";
                    }
                    text = (text + "x") + String.valueOf(numGot);
                }
                this.wordColors.add(new Color(1.0f, 1.0f, 1.0f, 1.0f));
                this.words.add(text);
            }
        }
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public void firstStep(Game game) {
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (this.timer > 90) {
            game.actionStack.remove(this);
            game.insertAction(this.nextAction);
        }
        this.timer++;
        int height = this.words.size();
        if (height < 2) {
            height = 2;
        }
        for (int i = 0; i < height; i++) {
            if (i == 0) {
                game.uiBatch.draw(this.textBoxTop, this.topLeft.x, this.topLeft.y - 19.0f);
            } else if (i == height - 1) {
                game.uiBatch.draw(this.textBoxBottom, this.topLeft.x, (this.topLeft.y - 19.0f) - ((float) (16 * i)));
            } else {
                game.uiBatch.draw(this.textBoxMiddle, this.topLeft.x, (this.topLeft.y - 19.0f) - ((float) (16 * i)));
            }
            this.color.set(game.uiBatch.getColor());
            if (i < this.words.size()) {
                String word = this.words.get(i);
                for (int j = 0; j < word.length(); j++) {
                    Sprite letterSprite = new Sprite((Sprite) game.textDict.get(Character.valueOf(word.charAt(j))));
                    letterSprite.setPosition(this.topLeft.x + 8.0f + ((float) (8 * j)), (this.topLeft.y - 14.0f) - ((float) (16 * i)));
                    game.uiBatch.setColor(this.color.r, this.color.g, this.color.b, this.wordColors.get(i).a);
                    game.uiBatch.draw(letterSprite, letterSprite.getX(), letterSprite.getY());
                }
            }
            game.uiBatch.setColor(this.color);
        }
    }
}
